<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('康熙分析列表')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>日期：</p>
                                <input name="date" class="form-control" site="20" placeholder="yyyy-MM-dd" th:value="${date}" type="text">
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="dict:kangxianalysis:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
     <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('dict:kangxianalysis:edit')}]];
        var removeFlag = [[${@permission.hasPermi('dict:kangxianalysis:remove')}]];
        var prefix = ctx + "dict/kangxianalysis";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "康熙分析",
                pageSize: 50,
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'id',
                    visible: false
                },
                {
                    field : 'date', 
                    title : '日期'
                },
                {
                    field : 'kkid', 
                    title : '用户ID'
                },
                {
                    field : 'analysis', 
                    title : '分析',
                    formatter: function(value, row, index) {
                        var datas = $.parseJSON(value)
                        var s = ''
                        datas.forEach(item => {
                           if(s){
                             s += '->'
                           }
                           var css = 'btn-white'
                           var tip = ''
                           if(item.action=='购买会员'){
                             css = 'btn-danger'
                           }else if(item.action == '点击起名'){
                              if(item.version == '20220527a'){
                                 css = 'btn-primary'
                                 tip = "&nbsp;&nbsp;<font color='red'>*new</font>"
                              }else{
                                 css = 'btn-success'
                              }
                           }
                           s += `<span class="btn-sm btn-lg ${css}">${item.action}[${item.time}](${item.total})${tip}</span>`;
                        })
                        return s
                    }
                }]
            };
            $.table.init(options);
        });

        $("input[name='date']").datetimepicker({
            format: "yyyy-mm-dd",
            weekStart: 1,
            autoclose: true,
            startView: 2,
            minView: 2,
            forceParse: false
        });

        $("input[name='date']").change(function(){
           var date = $(this).val();
           window.location = '/dict/kangxianalysis?date=' + date;
        });


    </script>
</body>
</html>